function ConnectedSelect(listID) {
	for(var i=0; listID[i]; i++){
		var select = new Object();			
		var obj = document.getElementById(listID[i]);			
		select.node = document.createElement("select");			
		var selectOptgroup = obj.getElementsByTagName("optgroup");
		while(selectOptgroup[0]){
			select.node.appendChild(selectOptgroup[0].cloneNode(true));
			obj.removeChild(selectOptgroup[0]);				
		}
		if(listID[i+1]){				
			select.nextSelect = document.getElementById(listID[i+1]);
			obj.onchange = function(){ ConnectedSelectOnchange(this) };
		}
		else
			select.nextSelect = false;
		obj.ConnectedSelect = select;
	}
}

function ConnectedSelectOnchange(select){
	if(select.selectedIndex < 0)
		select.selectedIndex = 0;
	var val = select.options[select.selectedIndex].value;
	if(val){		
		while(select.ConnectedSelect.nextSelect.options[1]) 
			select.ConnectedSelect.nextSelect.remove(1);
		
		var ef = false;
		for(var optG = select.ConnectedSelect.nextSelect.ConnectedSelect.node.firstChild; optG; optG = optG.nextSibling){				
			if(optG.label == val){
				ef = true;
				for(var op = optG.firstChild; op; op = op.nextSibling){
					select.ConnectedSelect.nextSelect.appendChild(op.cloneNode(true));
				}
			}
		}
		select.ConnectedSelect.nextSelect.disabled = !ef;
	}
	else {			
		select.ConnectedSelect.nextSelect.selectedIndex = 0;		
		while(select.ConnectedSelect.nextSelect.options[1]) 
			select.ConnectedSelect.nextSelect.remove(1);
		//select.ConnectedSelect.nextSelect.disabled = true;
	}
	if(select.ConnectedSelect.nextSelect.onchange)			
		select.ConnectedSelect.nextSelect.onchange();
}

//ConnectedSelect(["cate", "subcate", "child"]);	
function ModifySelect(id1, id2, val1, val2){	
	var obj = document.getElementById(id1);
	var select = new Object();	
	if(obj.ConnectedSelect) {				
		obj.ConnectedSelect.nextSelect = document.getElementById(id2);			
	}
	else{		
		select.nextSelect = document.getElementById(id2);
		obj.ConnectedSelect = select;		
	}
	obj.onchange = function(){ ConnectedSelectOnchange(this) };			
	
	select = new Object();
	select.node = document.createElement("select");
	obj = document.getElementById(id2);
	var selectOptgroup = obj.getElementsByTagName("optgroup");
	while(selectOptgroup[0]){
		select.node.appendChild(selectOptgroup[0].cloneNode(true));
		obj.removeChild(selectOptgroup[0]);
	}
	select.nextSelect = false;
	obj.ConnectedSelect = select;
	if(val1){
		var op1 = document.getElementById(id1);
		op1.value = val1;
		op1.onchange();			
	}
	if(val2){
		var op2 = document.getElementById(id2);		
		op2.value = val2;
		if(op2.selectedIndex < 0)
			op2.selectedIndex = 0;
	}
}